07. Create Resource Classes
Create Resource Classes
In this section, we will need to create the resource classes so we can provide an intermediary between the UI components and services. Resource classes are used for defining the Application Programming Interface (API).
Note: APIs are a best practice and used to separate backend software from frontend software. This provides a clean separation in behavior and responsibilities for the software components.
The hotel reservation application will have two resources, the HotelResource
intended for public usage and the AdminResource
intended for the hotel staff only.
Here are the main steps you'll need to complete to create the service classes:
Create a new package
Task Description:
Now it's time to create our api
package so we can start to add our api classes.
Task Feedback:
Nice work!
Create the HotelResource class
Task Description:
Next you'll need to create the ** HotelResource class**. The HotelResource should have little to no behavior contained inside the class and should make use of the Service classes to implement its methods. The HotelResource will have the following methods:
Task Feedback:
Nice work!
Create the AdminResource class
Task Description:
Next you'll need to create the ** AdminResource class**. The AdminResource should have little to no behavior contained inside the class and should make use of the Service classes to implement its methods. The AdminResource will have the following methods:
Task Feedback:
Nice work!